<?php

namespace App\Models;


class Order extends Orm
{
    //
    protected $table = 'order';
    protected $dateFormat = 'U';
    public $timestamps = true;
    protected $casts = [
        'goods_snap' => 'json',
    ];

    public function getPriceAttribute()
    {
        return sprintf("%.2f", $this->attributes['price']/100);
    }

    public function getPriceTotalAttribute()
    {
        return sprintf("%.2f", $this->attributes['price_total']/100);
    }

    public function getPayTotalAttribute()
    {
        return sprintf("%.2f", $this->attributes['pay_total']/100);
    }

    public function getPriceRealAttribute()
    {
        return sprintf("%.2f", $this->attributes['price_real']/100);
    }

    public function cycleInfo()
    {
        return $this->belongsTo(PriceCycle::class,  'cycle_id');
    }

    public function goodsInfo()
    {
        return $this->belongsTo(MemberPrice::class,  'g_id');
    }
}
